package com.sk.bilibili.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sk.bilibili.bean.Cover;
import com.sk.bilibili.other.R;
import com.sk.bilibili.service.CoverService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
* @author 邵康
* @date 2021/12/10 00:13
*/
@Api(tags = "临时的封面图片")
@CrossOrigin
@RestController
@RequestMapping("/cover")
public class CoverController {

    @Autowired
    private CoverService coverService;

    @ApiOperation("add")
    @PostMapping("/add")
    public R<Void> add( Cover cover){
        return coverService.add(cover);
    }

    @ApiOperation("delete")
    @GetMapping("/delete")
    public R<Void> delete(Integer id){
        return coverService.delete(id);
    }

    @ApiOperation("update")
    @PostMapping("/update")
    public R<Void> update( Cover cover){
        return coverService.update(cover);
    }

    @ApiOperation("page")
    @GetMapping("/page")
    public R<IPage<Cover>> page( @RequestParam(defaultValue = "1") Integer page,
                                @RequestParam(defaultValue = "10") Integer size){
        return coverService.page(page,size);
    }

    @ApiOperation("测试使用API  根据id获取对应数据")
    @GetMapping("/getCover")
    public R<Cover> getCover(Integer id){
        return coverService.getCover(id);
    }

}
